local youjiang = fk.CreateSkill {
  name = "steam__youjiang",
  tags = {Skill.AttachedKingdom},
  attached_kingdom = {"jin"},
}

Fk:loadTranslationTable{
  ["steam__youjiang"] = "幽降",
  [":steam__youjiang"] = "晋势力技，你造成或受到伤害时，你可改为向一名角色分配等量点体力上限，然后若获得者体力上限最多，你摸已损失体力值张牌。",
  ["#youjiang-choose"] = "幽降：你可向一名角色分配等量点体力上限，然后若获得者体力上限最多，你摸已损失体力值张牌。",
}
--受到伤害时时机
local spec= {
  anim_type = "defensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(youjiang.name) and target == player and player.maxHp>data.damage
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local damage=data.damage
    local players=room:getOtherPlayers(player)
    local tar= room:askToChoosePlayers(player, {
        targets = players,
        min_num = 1,
        max_num = 1,
        prompt = "#youjiang-choose",
        skill_name = youjiang.name,
        
      })
      if #tar>0 then
        room:changeMaxHp(tar[1], damage)
        room:changeMaxHp(player, -damage)
      end
      
      data:preventDamage()--防止伤害

    if not table.find(room.alive_players,function(p)
      return p.maxHp>tar[1].maxHp
    end) then
      local n=player:getLostHp()
      player:drawCards(n,youjiang.name)
    end
  end,
}
--fk.DamageInflicted
youjiang:addEffect(fk.DamageInflicted,spec)

youjiang:addEffect(fk.DamageCaused,spec)




return youjiang